package com.wangxue.stock.controller;

import com.wangxue.stock.service.UserService;
import com.wangxue.stock.vo.req.LoginReqVo;
import com.wangxue.stock.vo.resp.LoginRespVo;
import com.wangxue.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author wangxue
 * @Date 2022/05/16
 * @Description 定义用户访问层
 */
@RestController
@RequestMapping("/api")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 用户登录功能实现
     * @param vo
     * @return * @return R<LoginRespVo>
     * @author wangxue
     */
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
       R<LoginRespVo> r = this.userService.login(vo);
        return r;
    }
    /**
     * 生成验证码
     *   map结构：
     *        code: xxx,
     *        rkey: xxx
     *
     * @return R<Map>
     * @author wangxue
     * @Date 2022/5/19
     */
    @GetMapping("/captcha")
    public R<Map> generateCaptcha(){
        return userService.generateCaptcha();
    }

   /* @GetMapping("/test")
    public String getName(){
        return "sophia";
    }*/

}
